package com.begye.smartloan.apptest.huankuan

import android.annotation.SuppressLint
import android.os.Bundle
import android.view.View
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import com.begye.smartloan.apptest.R
import com.begye.smartloan.apptest.daohang.DaoHangBottom
import com.begye.smartloan.apptest.databinding.AtHuanKuanBinding
import com.begye.smartloan.apptest.ext.addUnderLine
import com.begye.smartloan.apptest.kefu.KeFuDialogFragment
import com.begye.smartloan.apptest.shenhezhong.ShenHeZhongActivity
import com.begye.smartloan.apptest.tool.addTouch
import com.util.utillib.extend.IntentFlagMode
import com.util.utillib.extend.toNextActivity


@SuppressLint("CustomWelcomeScreen")
class HuanKuanFangKuanZhongActivity : AppCompatActivity() {

    private lateinit var _binding: AtHuanKuanBinding

    @SuppressLint("NotifyDataSetChanged")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()

        _binding = AtHuanKuanBinding.inflate(layoutInflater)
        setContentView(_binding.root)

        configYongHuLiuChengState()
        configUIState()
        configUIEvent()
        configUIData()
    }

    private fun configYongHuLiuChengState() {
    }

    @SuppressLint("NotifyDataSetChanged")
    private fun configUIState() {

    }

    private fun configUIEvent() {

        _binding.atHuanKuanListContent.visibility = View.GONE
        _binding.atHuanKuanNoneData.visibility = View.VISIBLE

        _binding.atHuanKuanNarBar.initConfig(
            leftResId = R.drawable.dres_139,
            rightResId = R.drawable.dres_84
        ) {
            if (0 == it) {
                _binding.atHuanKuanCouTiDrawer.refresh(this@HuanKuanFangKuanZhongActivity) {
                    if (_binding.atHuanKuanRootLayout.isDrawerOpen(_binding.atHuanKuanCouTiDrawer)) {
                        _binding.atHuanKuanRootLayout.closeDrawer(_binding.atHuanKuanCouTiDrawer)
                    }
                }

                if (_binding.atHuanKuanRootLayout.isDrawerOpen(_binding.atHuanKuanCouTiDrawer)) {
                    _binding.atHuanKuanRootLayout.closeDrawer(_binding.atHuanKuanCouTiDrawer)
                } else {
                    _binding.atHuanKuanRootLayout.openDrawer(_binding.atHuanKuanCouTiDrawer)
                }
            } else if (1 == it) {
                val dialog = KeFuDialogFragment()
                dialog.showNow(supportFragmentManager, "kefu")
            }
        }

        _binding.atHuanKuanNoneDataToAp.addUnderLine()
        _binding.atHuanKuanNoneDataToAp.setOnClickListener {
            toNextActivity(
                activity = ShenHeZhongActivity::class.java,
                mode = IntentFlagMode.SINGLE_TOP
            )
        }

        _binding.atHuanKuanBottom.initConfig(type = DaoHangBottom.TYPE_HUAN_KUAN) {
            if (it == DaoHangBottom.TYPE_HOME) {
                toNextActivity(
                    activity = ShenHeZhongActivity::class.java,
                    mode = IntentFlagMode.SINGLE_TOP
                )
            }
        }
    }

    private fun configUIData() {
    }

    override fun onResume() {
        super.onResume()

        addTouch(type = this.javaClass.simpleName, isOpen = true)
    }

    override fun onPause() {
        super.onPause()

        addTouch(type = this.javaClass.simpleName, isComplete = true)
    }
}

